package com.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;

import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import com.world.World;

import entities.hero.Hero;

public class EndScreen implements Screen {	 
	private TiledMap map;
	private World world;
	private OrthogonalTiledMapRenderer renderer; 
	private OrthographicCamera camera;
	private BitmapFont font;
	
	private String endMessage;
	private Start game;
	
	public EndScreen(Start game, String endMessage) {	
		this.game = game;
		
		world = new World();
		map = world.getMap();
		
		renderer = new OrthogonalTiledMapRenderer(map);
		camera = new OrthographicCamera();
		
		font = new BitmapFont();

		this.endMessage = endMessage;
	}
	
	@Override
	public void show() {

	}
	
	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(0, 0, 0, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		
		renderer.setView(camera);
		renderer.render();
		
		font.setColor(1.0f, 1.0f, 1.0f, 1.0f);
		renderer.getSpriteBatch().begin();
		font.draw(renderer.getSpriteBatch(), endMessage, 512 - 50, 384);
		renderer.getSpriteBatch().end();
	
		if (Gdx.input.isTouched()) {
			game.setScreen(new MenuScreen(game));
			dispose();
		}
	}

	@Override
	public void resize(int width, int height) {
		camera.viewportHeight = height;
		camera.viewportWidth = width;
		 
		camera.setToOrtho(false, World.WIDTH, World.HEIGHT);
		camera.update();
	}
	
	@Override
	public void dispose() {
		font.dispose();
		map.dispose();
		renderer.dispose();
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}
	
	public static Hero checkForPlayer() {
		return null;
	}

	@Override
	public void hide() {
		
	}
}
